/**
 * 病历审阅界面患者的就诊日期信息列表datagrid表格展示
 */
//页面初始化加载js脚本
$(function(){
	var gridData = [{orgName: '张三诊所', clinicDate: '2015-06-23',drName:'王强'},
	 /*病历数据*/     {orgName: '爱民诊所', clinicDate: '2015-08-28',drName:'王强'},
	         	    {orgName: '西瑶诊所', clinicDate: '2015-09-13',drName:'王强'}];
	//患者的就诊日期 展示datagrid 
	$('#pcaseViewGrid').datagrid({   
	    singleSelect:true,
	    rownumbers:true,
	    columns:[[    
	        {field:'clinicDate',title:'就诊日期',width:'33%',halign:'center'}, 
	        {field:'orgName',title:'中医馆',width:'30%',halign:'center'},  
	        {field:'drName',title:'就诊医生',width:'32%',halign:'center'}    
	    ]] ,
	    data: gridData,
		sortable:true,
		onClickCell: function(index,field,value){
			showpcaseInfo();
		}
	});
	/**
	 * 中医诊断的datagrid数据表格配置
	*/
	$('#pcaseWriteGrid').datagrid({   //患者的就诊日期 展示datagrid 
		rownumbers:true,
		columns:[[ 
		     {field:'type',title:'诊断类型',width:'33%',halign:'center'},
		     {field:'name',title:'诊断名称',width:'32%',halign:'center'},
		     {field:'description',title:'描述',width:'30%',halign:'center'}
	    ]], 
	});
	/*中医检查的表格配置*/
	$('#inspectGrid').datagrid({   
	    singleSelect:true,
	    rownumbers:true,
	    columns:[[    
	        {field:'type',title:'检查日期',width:'25%',halign:'center'}, 
	        {field:'name',title:'检查医生',width:'25%',halign:'center'},  
	        {field:'description',title:'项目名称',width:'22%',halign:'center'},
	        {field:'type',title:'数量',width:'22%',halign:'center'}
	    ]],
		sortable:true
	});
	/*中医处方的表格配置*/
	$('#prescriptionGrid').datagrid({   
	    singleSelect:true,
	    rownumbers:true,
	    columns:[[    
	        {field:'type',title:'处方日期',width:'33%',halign:'center'}, 
	        {field:'name',title:'处方医生',width:'32%',halign:'center'},  
	        {field:'description',title:'处方内容',width:'30%',halign:'center'}
	    ]],
		sortable:true
	});
});

function showpcaseInfo(){
	var data={bloodType: "q",
			bmi: "12.00",
			bpH: "123",
			bpL: "12",
			breathing: "223",
			butbocksline: "123.00",
			contactPhone: "",
			edema: "ghn",
			eyegroundD: "wcdcdf",
			footD: "trgtr",
			footS: "srzzbrt",
			gender: "男",
			heart: "vdf",
			heartRate: "12",
			identifyCardID: "",
			individualHis: "afe",
			liver: "vf",
			localDisHis: "afee",
			lung: "vfg",
			name: "weewe",
			neckD: "vfddf",
			neckJ: "vfffd",
			nowAddress: "sss",
			otherCheck: "srttr",
			paunchCm: "213.00",
			priDepict: "afe",
			pulse: "12",
			pulseInfo: "滑,弦,",
			shezhi: "胖大,舌暗,",
			sight: "31232",
			stature: "23.00",
			tongue: "苔白,苔厚,",
			waistlineCm: "213.00",
			waistlineExe: "123.00",
			weight: "12.00",
			data:[{'type':'1','name':'2','description':'3'},
			      {'type':'2','name':'1','description':'3'}]};
//	var width = document.body.clientWidth*0.7>800?document.body.clientWidth*0.7:800;
//	var height = 30+data.data.length*25;
//	$('#pcaseWriteGrid').datagrid('resize', {
//        width:width,
//        height:height
//    });
//	$('#inspectGrid').datagrid('resize', {
//        width:width,
//        height:height
//    });
//	$('#prescriptionGrid').datagrid('resize', {
//        width:width,
//        height:height
//    });
	//隐藏的不为空，显示值域
	$('.inspect-list label').each(function(){
		var id=this.htmlFor;
		if(data[id]!="")
		$('#'+id).toggle();
	});
	$('#pcaseWriteGrid').datagrid('loadData', data.data);
	$('#inspectGrid').datagrid('loadData', data.data);
	$('#prescriptionGrid').datagrid('loadData', data.data);
	//form表单的数据重载
	$('#patientCaseForm').form('load', data);
	//中医查体
	pulseInfo=data.pulseInfo.split(",");
	pulseInfoLength=data.pulseInfo.length;
	for(var i=0;i<pulseInfoLength-1;i++){
		$("input[name='pulseInfo'][value=\'"+pulseInfo[i]+"\']").attr("checked", "checked");
	}
	pulseInfo=data.pulseInfo.split(",");
	pulseInfoLength=data.pulseInfo.length;
	for(var i=0;i<pulseInfoLength-1;i++){
		$("input[name='pulseInfo'][value=\'"+pulseInfo[i]+"\']").attr("checked", "checked");
	}
	tongue=data.tongue.split(",");
	tongueLength=data.tongue.length;
	for(var i=0;i<tongueLength-1;i++){
		$("input[name='tongue'][value=\'"+tongue[i]+"\']").attr("checked", "checked");
	}
	shezhi=data.shezhi.split(",");
	shezhiLength=data.tongue.length;
	for(var i=0;i<shezhiLength-1;i++){
		$("input[name='shezhi'][value=\'"+shezhi[i]+"\']").attr("checked", "checked");
	}
	
}